package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;

/**
 * 多垛理货解锁详情
 *
 * @author ：dujianyu
 * @since ：Created in 2024/6/18 10:30
 */
@Data
public class TwoStockTallyUnlockDetailVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportBillId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportShipId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long toTransportBillId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long toTransportShipId;

    @ApiModelProperty(value = "作业前船名")
    private String oriShipNameZh;

    @ApiModelProperty(value = "作业后船名")
    private String toShipNameZh;

    @ApiModelProperty(value = "作业前船进出口")
    private String oriIE;

    @ApiModelProperty(value = "作业前船进出口")
    private String oriIEName;

    public String getOriIEName() {
        if (Func.isNull(oriIE)) {
            return "";
        }
        return "Y".equals(oriIE) ? "是" : "否";
    }

    @ApiModelProperty(value = "作业前单号")
    private String oriBillNo;

    @ApiModelProperty(value = "作业后单号")
    private String toBillNo;

    @ApiModelProperty(value = "作业前航次")
    private String oriVoyage;

    @ApiModelProperty(value = "作业前货主")
    private String oriCargoOwner;

    @ApiModelProperty(value = "作业前货主")
    private String oriCargoOwnerName;

    @ApiModelProperty(value = "作业前联系电话")
    private String oriContactPhone;

    @ApiModelProperty(value = "作业前舱单货名")
    private String oriBillCargoType;

    @ApiModelProperty(value = "作业前舱单货名")
    private String oriBillCargoTypeName;

    @ApiModelProperty(value = "作业前舱单包装")
    private String oriPackageType;

    @ApiModelProperty(value = "作业前舱单包装")
    private String oriPackageTypeName;

    @ApiModelProperty(value = "作业前计划件数")
    private Integer oriPlanPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业前计划吨数")
    private BigDecimal oriPlanTon;

    @ApiModelProperty(value = "作业前计划件吨信息")
    private String oriPlanPieceTonInfo;

    public String getOriPlanPieceTonInfo() {
        if (Func.isNull(oriPlanPiece) || Func.isNull(oriPlanTon)) {
            return "";
        }
        return oriPlanPiece + "/" + oriPlanTon.stripTrailingZeros().toPlainString();
    }

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业前计划单吨")
    private BigDecimal oriPlanPerTon;

    public BigDecimal getOriPlanPerTon() {
        if (Func.isNull(oriPlanPiece) || Func.isNull(oriPlanTon) || oriPlanPiece == 0 || "BU".equals(oriPackageType)) {
            return new BigDecimal(0);
        }
        return oriPlanTon.divide(new BigDecimal(oriPlanPiece), RoundingMode.CEILING).stripTrailingZeros();
    }

    @ApiModelProperty(name = "计划泊位",notes = "")
    private String planBerth ;

    @ApiModelProperty(name = "计划泊位",notes = "")
    private String planBerthName ;

    @ApiModelProperty(name = "实际泊位",notes = "")
    private String lastBerth ;

    @ApiModelProperty(name = "实际泊位",notes = "")
    private String lastBerthName ;

    @ApiModelProperty(value = "理货日期")
    private LocalDate tallyDate;

    @ApiModelProperty(value = "时间段")
    private String timeSpace;

    @ApiModelProperty(value = "时间段")
    private String timeSpaceName;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "理货类型")
    private String tallyType;

    @ApiModelProperty(value = "理货类型")
    private String tallyTypeName;

    public String getTallyTypeName() {
        if (Func.isNull(tallyType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TALLY_TYPE, tallyType);
    }

    @ApiModelProperty(value = "航陆运")
    private String shipLand;

    @ApiModelProperty(value = "航陆运")
    private String shipLandName;

    public String getShipLandName() {
        if (Func.isNull(shipLand)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.SHIP_LAND, shipLand);
    }

    @ApiModelProperty(value = "作业过程")
    private String operationType;

    @ApiModelProperty(value = "作业过程")
    private String operationTypeName;

    @ApiModelProperty(value = "作业活动")
    private String workActivity;

    @ApiModelProperty(value = "作业活动")
    private String workActivityName;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "保管员",notes = "")
    private Long keeper ;

    @ApiModelProperty(name = "保管员",notes = "")
    private String keeperName ;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "作业前垛位Id",notes = "")
    private Long oriStorageId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "作业前垛位货场",notes = "")
    private Long oriStoragePositionId;

    @ApiModelProperty(name = "作业前垛位货场",notes = "")
    private String oriStoragePositionName ;

    @ApiModelProperty(name = "作业前垛位货位",notes = "")
    private String oriStorageSpot ;

    @ApiModelProperty(name = "作业前垛位包装",notes = "")
    private String oriStoragePackageType ;

    @ApiModelProperty(name = "作业前垛位包装",notes = "")
    private String oriStoragePackageTypeName ;

    @ApiModelProperty(name = "作业前垛位货场",notes = "")
    private String oriTallyPackageType ;

    @ApiModelProperty(name = "作业前垛位货位",notes = "")
    private String oriTallyPackageTypeName ;

    @ApiModelProperty(name = "作业前理货件",notes = "")
    private Integer oriTallyPiece ;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业前理货吨")
    private BigDecimal oriTallyTon ;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "作业后垛位Id",notes = "")
    private Long toStorageId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "作业后垛位货场",notes = "")
    private Long toStoragePositionId;

    @ApiModelProperty(name = "作业后垛位货场",notes = "")
    private String toStoragePositionName ;

    @ApiModelProperty(name = "作业后垛位货位",notes = "")
    private String toStorageSpot ;

    @ApiModelProperty(name = "作业后垛位包装",notes = "")
    private String toStoragePackageType ;

    @ApiModelProperty(name = "作业后垛位包装",notes = "")
    private String toStoragePackageTypeName ;

    @ApiModelProperty(name = "作业后垛位货场",notes = "")
    private String toTallyPackageType ;

    @ApiModelProperty(name = "作业后垛位货位",notes = "")
    private String toTallyPackageTypeName ;

    @ApiModelProperty(name = "作业后理货件",notes = "")
    private Integer toTallyPiece ;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业后理货吨")
    private BigDecimal toTallyTon ;

    @ApiModelProperty(name = "作业前后位置信息",notes = "")
    private String positionInfo ;

    public String getPositionInfo() {
        if (Func.isNull(oriStorageId) || Func.isNull(toStorageId)) {
            return "";
        }
        return oriStoragePositionName +
                "/" +
                oriStorageSpot +
                "->" +
                toStoragePositionName +
                "/" +
                toStorageSpot;
    }

    @ApiModelProperty(name = "作业前后包装信息",notes = "")
    private String tallyPackageTypeInfo ;

    public String getTallyPackageTypeInfo() {
        if (Func.isNull(oriTallyPackageTypeName) || Func.isNull(toTallyPackageTypeName)) {
            return "";
        }
        return oriTallyPackageTypeName + "->" + toTallyPackageTypeName;
    }

    @ApiModelProperty(name = "作业前后件数信息",notes = "")
    private String tallyPieceInfo ;

    public String getTallyPieceInfo() {
        if (Func.isNull(oriTallyPiece) || Func.isNull(toTallyPiece)) {
            return "";
        }
        return oriTallyPiece + "->" + toTallyPiece;
    }

    @ApiModelProperty(name = "作业前后吨数信息",notes = "")
    private String tallyTonInfo ;

    public String getTallyTonInfo() {
        if (Func.isNull(oriTallyTon) || Func.isNull(toTallyTon)) {
            return "";
        }
        return oriTallyTon.stripTrailingZeros().toPlainString() + "->" + toTallyTon.stripTrailingZeros().toPlainString();
    }

    @ApiModelProperty(name = "作业前后吨数信息",notes = "")
    private String workerInfo ;

    @ApiModelProperty(name = "作业前后吨数信息",notes = "")
    private String machineInfo ;

    @ApiModelProperty(name = "安全生产",notes = "")
    private String isSafeProduction ;

    @ApiModelProperty(name = "安全生产",notes = "")
    private String isSafeProductionName ;

    public String getIsSafeProductionName() {
        if (Func.isNull(isSafeProduction)) {
            return "";
        }
        return "Y".equals(isSafeProduction) ? "是" : "否";
    }

    @ApiModelProperty(name = "作业舱",notes = "")
    private String hold ;

    @ApiModelProperty(name = "作业舱",notes = "")
    private String holdName ;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "理货员",notes = "")
    private Long createUser;

    @ApiModelProperty(name = "理货员",notes = "")
    private String createUserName;
}
